import axios from 'axios'

axios.defaults.baseURL = 'http://api-toutiao-web.itheima.net'

axios.interceptors.request.use(function (config) {
  const tokenStr = localStorage.getItem('token')
  if (tokenStr) {
    config.headers.Authorization = tokenStr
  }
  return config
}, function (error) {
  return Promise.reject(error)
})

export default axios
